<template>
	<view class="integral-goods-list-page">
		<view class="header-box">
			<image src="../../static/images/bg_1.png" mode="widthFix" class="bg-img"></image>
			<image src="../../static/images/icon_1.png" mode="widthFix" class="bg-icon"></image>
			<view class="top-bar">
				<image src="../../static/images/bg_1.png" mode="" class="avatar"></image>
				<text class="text">用户姓名</text>
			</view>
			<view class="content">
				<view class="label">当前积分</view>
				<view class="row">
					<view class="value">9964</view>
					<view class="btn">积分记录></view>
				</view>
			</view>
		</view>
		<view class="contain">
			<view class="tab-box">
				<view class="tab active">我可兑换</view>
				<view class="tab">全部商品</view>
			</view>
			<view class="goods-list">
				<view class="item">
					<view class="img-box">
						<image src="../../static/images/bg_1.png" mode="" class="img"></image>
					</view>
					<view class="info-box">
						<view class="name">天堂黑胶防晒扁伞</view>
						<view class="num">剩余 19件</view>
						<view class="btn">
							<image src="../../static/images/bg_2.png" mode="" class="img"></image>
							<view class="value-box">
								<text class="value">598</text>
								<text class="text">积分</text>
							</view>
							<view class="btn-text">兑换</view>
						</view>
					</view>
				</view>
			<loading-footer :status="status"></loading-footer>
<!-- 			<view class="empty-box">
				<image src="../../static/images/empty.png" mode="widthFix" class="img"></image>
				<text class="text">暂无可兑换商品</text>
			</view> -->
			</view>
		</view>

	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		getHome,
		getMenu,
		getBestList
	} from '@/api/store';
	import {
		loadingType
	} from '@/utils/type'
	import {
		loadingFun,
		menuJump,
		arraySlice,
		getRect
	} from '@/utils/tools'
	import {
		toLogin
	} from '@/utils/login'
	import Cache from '@/utils/cache'
	const app = getApp()
	export default {
		options: {
			"styleIsolation": "apply-shared"
		},
		data() {
			return {
				navSwiperH: 374,
				logo: "",
				currentSwiper: 0,
				page: 1,
				status: loadingType.LOADING,
				remainTime: "",
				navBg: 0,
				news: [],
				goodsList: [],
				seckill: {},
				seckillGoods: [],
				hotGoods: [],
				newGoods: [],
				activityArea: [],
				showCoupop: false,
				enable: true,
				isShowDownload: false,
				scrollTop: 0,

				tabHotActiveIndex: 0,
			}
		},
		async onLoad(options) {

			this.getBestListFun()

		},
		async onShow() {
			await this.getHomeFun()
			await this.getCartNum()
		},
		onReachBottom() {
			this.getBestListFun()
		},
		onPullDownRefresh() {
			this.getHomeFun()
		},
		onShareAppMessage() {
			console.log(this.inviteCode)
			const shareInfo = Cache.get('shareInfo')
			return {
				title: shareInfo.mnp_share_title,
				path: "pages/index/index?invite_code=" + this.inviteCode,
				imageUrl: shareInfo.mnp_share_bg,
			};
		},
		onPageScroll(e) {
			const top = uni.upx2px(100)
			const {
				scrollTop
			} = e
			if (!this.enable) return
			let percent = scrollTop / top
			this.navBg = percent > 1 ? 1 : percent
			this.scrollTop = scrollTop

		},

		methods: {
			...mapActions(['getCartNum']),

			async getHomeFun() {
				const {
					code,
					data
				} = await getHome();
				uni.stopPullDownRefresh()
				if (code == 1) {
					const {
						news,
						seckill = {},
						host_goods,
						shop_logo,
						new_goods,
						activity_area
					} = data;

					this.seckillGoods = seckill.goods
					this.seckill = seckill
					this.hotGoods = host_goods
					this.newGoods = new_goods
					this.activityArea = activity_area

				}
			},
			async getBestListFun() {
				let {
					page,
					goodsList,
					status
				} = this
				const data = await loadingFun(getBestList, page, goodsList, status)
				if (!data) return
				this.page = data.page
				this.goodsList = data.dataList
				this.status = data.status
			},


		},
		computed: {
			...mapGetters(["cartNum", "inviteCode", "appConfig"]),


		}
	}
</script>

<style lang="scss" scoped>
	@import "index.scss";
</style>